//
//  WelcomeViewController.m
//  SinaWebo
//
//  Created by wwj on 16/6/16.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "WelcomeViewController.h"
#import "UserPerfenceUtil.h"
#import "TabBarViewController.h"
#import <UIImageView+WebCache.h>

@interface WelcomeViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *headImg;
@property (weak, nonatomic) IBOutlet UILabel *welLabel;

@end

@implementation WelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [UIApplication sharedApplication].statusBarHidden = YES;
    self.welLabel.alpha = 0.0;
    
    
    [self.headImg sd_setImageWithURL:[NSURL URLWithString:[UserPerfenceUtil account].avatar_hd] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        [UIView animateWithDuration:1.5 delay:0.0 usingSpringWithDamping:0.6 initialSpringVelocity:0.0 options:UIViewAnimationOptionCurveLinear animations:^{
            self.headImg.y -= 20;
        }completion:^(BOOL finished) {
            [UIView animateWithDuration:0.3 animations:^{
                self.welLabel.alpha = 1.0;
            }completion:^(BOOL finished) {
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [UIApplication sharedApplication].keyWindow.rootViewController=[[TabBarViewController alloc]init];
                });
            }];
        }];
    }];
}


@end
